{% extends "base.html" %}
{% block subject %} List of car records {%  endblock %}
{% block content %}
{% if cars %}
<span class="label label-important">number of records : {{ cars.count }} </span>
<p></p>
<table class="table table-hover table-condensed table-striped">
    <tr>
        <th> Brand </th>
        <th> Model</th>
        <th> Chase. no </th>
        <th> Year </th>
        <th> Owner </th>
        <th> Reg. Expiry</th>
        <th> Insurance Expiry</th>
        <th> Checkup Expiry</th>
    </tr>

    {% for p in cars  %}
        <tr>

            <td>{{ p.brand }} </td>
            <td><a  href="{{p.chase_no}}/details">{{ p.car_model }} </a></td>
            <td><a  href="{{p.chase_no}}/details">{{ p.chase_no }} </a> </td>
            <td><a  href="{{p.chase_no}}/details">{{ p.year }} </a> </td>
            {%  if p.user %}
                <td><a  href="{{p.chase_no}}/details">{{ p.user }} </a> </td>
            {% else %}
                <td><a  href="{{p.chase_no}}/details">{{ p.company }} </a> </td>
            {% endif %}

            {%  if p.cal_exp < 91 %}
                <td><span class="label label-important"> <a  href="{{p.chase_no}}/details">{{ p.expiry_date }} </a> </span></td>
            {% else %}
                <td><a  href="{{p.chase_no}}/details">{{ p.expiry_date }} </a> </td>
            {% endif %}

            {%  if p.cal_inssurance < 91 %}
                <td><span class="label label-important"> <a  href="{{p.chase_no}}/details">{{ p.insurance_end }} </a> </span></td>
            {% else %}
                <td><a  href="{{p.chase_no}}/details">{{ p.insurance_end }} </a> </td>
            {% endif %}

            {%  if p.cal_checkup < 91 %}
                <td><span class="label label-important"> <a  href="{{p.chase_no}}/details">{{ p.checkup_expiry }} </a></span> </td>
            {% else %}
                <td><a  href="{{p.chase_no}}/details">{{ p.checkup_expiry }} </a> </td>
            {% endif %}

        </tr>
    {%  endfor %}
</table>

{% endif %}

{% endblock %}